package com.dikang.yygh.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dikang.yygh.model.order.OrderInfo;
import com.dikang.yygh.vo.order.OrderCountQueryVo;
import com.dikang.yygh.vo.order.OrderCountVo;
import com.dikang.yygh.vo.order.OrderQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
    @Select("<script>"+
            " select reserve_date as reserveDate, count(reserve_date) as count" +
            "        from order_info"+
            "   <where>"+
            "  <if test='vo.hosname != null and vo.hosname != \"\"'>" +
            "   and hosname like CONCAT('%',#{vo.hosname},'%')" +
            "</if>"+
            " <if test='vo.reserveDateBegin != null and vo.reserveDateBegin != \"\"'>" +
            "      and reserve_date >= #{vo.reserveDateBegin}" +
            " </if>"+
            " <if test='vo.reserveDateEnd != null and vo.reserveDateEnd != \"\"'>" +
            "  and reserve_date &lt;= #{vo.reserveDateEnd}" +
            "            </if>" +
            "            and is_deleted = 0"+
            "   </where>"+
          " group by reserve_date"  +
          " order by reserve_date"+
            " </script>")
    List<OrderCountVo> selectOrderCount(@Param("vo") OrderCountQueryVo orderCountQueryVo);
}

